package com.example.administrator.a0012toast;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    /*
      点击
     */
    public void showToast(View v){
        //makeText(创建toast上下文对象，表示弹出提示信息，toast持续时间，单位毫秒)
        Toast toast = Toast.makeText(this,"我是toast",Toast.LENGTH_LONG);
        //setGravity(当前toast的位置，x偏移量，y偏移量)
        toast.setGravity(Gravity.CENTER,0,0);
        //展示toast
        toast.show();
    }
}
